<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
      // 每个promise对象都会有一个then方法，这个方法是预定义的
      //每个then方法都有两个回调，1.onResolved回调 2.onRejected回调
//onResolved会在调用resolve的时候执行，会把resolved里传的参数以形参的形式传递到onResolved里。onRejected同理
      let p = new Promise((resolve, reject) => {
        resolve("成功啦");
      });

      p.then(
        (res) => {
          console.log("onResolved执行了", res);
        },
        () => {
          console.log("onRejected执行了");
        }
      );
    </script>
  </body>
</html>
